package com.study.spark.scala.chapter11

import com.study.spark.scala.chapter08.Scala05_Match.User

object Scala02_Generic_1 {
  def main(args: Array[String]): Unit = {
    // TODO scala中的泛型和java中大同小异
    // scala中泛型也存在上限和下限，采用颜文字表示
    // 上限
    val parent : Parent = new Parent()
    val user : User = new User()
    val subuser : SubUser = new SubUser()
//    test[Parent](parent) // Error
    test[User](user)   // OK
    test[SubUser](subuser) // OK
  }
  def  test[A<:User]( a : A ): Unit = {
    println(a)
  }
  class Parent {
  }
  class User extends Parent{
  }
  class SubUser extends User {
  }
}
